/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package converters;


import entities.AccionEstrategica;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author curso
 */
@FacesConverter("AccionConverter")
public class AccionConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        String cad[]=value.split("__");
        AccionEstrategica ae =new AccionEstrategica();
        ae.setNombreAccionEstrategica(cad[0]);
        ae.setEstatus(Boolean.parseBoolean(cad[1]));
        ae.setId(Long.parseLong(cad[2]));
        
        
        return ae;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        AccionEstrategica ae =(AccionEstrategica)value;
        String cad = ae.getNombreAccionEstrategica()+"__"+ae.getEstatus()+"__"+ae.getId();
        return cad;
    }
    
}
